<?php
require_once('Zend/Queue/Adapter/Db.php');

class Myzen_Queue_Adapter_ShardDb extends Zend_Queue_Adapter_Db {

    /**
     * Constructor
     *
     * @param  array|Zend_Config $options
     * @param  Zend_Queue|null $queue
     * @return void
     */
    public function __construct($options, Zend_Queue $queue = null)
    {
        parent::__construct($options, $queue);
        
        
    }
    
    
     /**
     * Initialize Db adapter using 'driverOptions' section of the _options array
     *
     * Throws an exception if the adapter cannot connect to DB.
     *
     * @return Zend_Db_Adapter_Abstract
     * @throws Zend_Queue_Exception
     */
    protected function _initDbAdapter()
    {
        return Zend_Registry::get('dt_dbs')->getDb('asynchronous','queue','key');
    }
    
    
    
     /**
     * Send a message to the queue
     *
     * @param  Myzen_Queue_AsynchronousJobMessage $message message
     * @return $this
     * @throws Zend_Queue_Exception
     */

    public function send($message, Zend_Queue $queue = null) {
        if ($message instanceof Myzen_Queue_AsynchronousJobMessage) {
            $response = parent::send($message->__toString());
        } else {
			$response = parent::send($message,$queue);
		}
        return $this;
    }

    	
}